﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using table_select;
using System.Text.RegularExpressions;


public partial class _Default : System.Web.UI.Page
{


    protected void Page_Load(object sender, EventArgs e)
    {

       Label1.Text = DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日     星期" + DateTime.Now.ToString("ddd", new System.Globalization.CultureInfo("zh-cn"))  ;     
    }





 




    protected void Button1_Click(object sender, EventArgs e)
    {
        Regex r = new Regex("^[0-9]*$");
        Match m = r.Match(this.TextBox1.Text);
        if (!(m.Success))
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            Response.Write("<script>alert('用户名请用“纯数字”输入！');</script>");
            return;

        }
        Session.Add("test","on");
       
        string sql = "select system_users.user_id,psw,name from system_users,zd_ry where system_users.user_id='"
               + TextBox1.Text.ToString().Trim() + "'and psw='" + TextBox2.Text.ToString().Trim() +
               "'and system_users.user_id=zd_ry.user_id ";
     
        
        DataTable da1 = tablesel.con_open(sql);
     
        
        if (da1.Rows.Count != 0)
        {

            //设置须传递参数
            Session["userid"] = da1.Rows[0][0].ToString();
            Session["password"] = da1.Rows[0][1].ToString();
            Session["name"] = da1.Rows[0][2].ToString();

            //if (datable_select.da_open(sql).Rows.Count != 0)
            //登录
            Response.Redirect("xinxike_zhuye.aspx");
        }
        else
            Response.Write("<script>alert('请输入正确的用户名和密码！');</script>");
    
    
    
    
    }

   


    protected void Button2_Click(object sender, EventArgs e)
    {

        string sql3 = "select system_users.user_id,psw,name from system_users,zd_ry where system_users.user_id='"
   + TextBox1.Text.ToString().Trim() + "'and psw='" + TextBox2.Text.ToString().Trim() +
   "'and system_users.user_id=zd_ry.user_id ";

        DataTable da2 = tablesel.con_open(sql3);


        if (da2.Rows.Count != 0)
        {
            //设置须传递参数
            Session["userid"] = da2.Rows[0][0].ToString();
            Session["password"] = da2.Rows[0][1].ToString();
            Session["name"] = da2.Rows[0][2].ToString();

            TextBox1.Text = "";
            TextBox2.Text = "";

            Response.Redirect("modifypwd.aspx");
        }
        else
        {
            Response.Write("<script>alert('请输入正确的用户名和密码！');</script>");
        } 
    }
}
